package one.stand.controller;

import one.stand.model.CompanyApplyRecordModel;
import one.stand.model.ResultModel;
import one.stand.request.CompanyCategoryModelRequest;
import one.stand.service.CompanyApplyService;
import one.stand.service.CompanyCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by yandou on 2019/6/16.
 */
@RestController
@RequestMapping("/company/apply")
public class CompanyApplyController extends BaseController {

    @Autowired
    private CompanyApplyService companyApplyService;
    @Autowired
    private CompanyCategoryService companyCategoryService;

    @PostMapping("category/list")
    ResultModel companyCategoryList(@RequestBody CompanyCategoryModelRequest request) {
        return companyCategoryService.list(request);
    }

    /**
     * 获取可代理厂家列表
     *
     * @param request
     * @return
     */
    @PostMapping("list")
    ResultModel applyList(@RequestBody CompanyApplyRecordModel request) {
        return companyApplyService.applyCompanyList(request);
    }

    @PostMapping("supply/list")
    ResultModel supplyList(@RequestBody CompanyApplyRecordModel request) {
        request.setApplyCompanyId(request.getCId().intValue());
        return companyApplyService.list(request);
    }

    @PostMapping("updateState")
    ResultModel updateState(@RequestBody CompanyApplyRecordModel request) {
        return companyApplyService.updateState(request);
    }

    @PostMapping("add")
    ResultModel add(@RequestBody CompanyApplyRecordModel request) {
        return companyApplyService.add(request);
    }

}
